#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
struct node{
	int d, v, a;
}x[maxn];
int p[maxn];
int n, m, L, V;
int f[3005][3005], g[3005], h[3005], dis[maxn];
namespace A{
	void solve() {
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++) {
				if (p[j] - x[i].d >= 0 && (x[i].v * x[i].v + 2 * x[i].a * (p[j] - x[i].d)) > V * V) f[i][j] = 1;
				else f[i][j] = 0;
			}
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			int fl = 0;
			for (int j = 1; j <= m; j++) {
				if (f[i][j] == 1) {
					g[i] = 1;
					fl = 1;
					break;
				}
			}
			if (fl == 1) ans++;
		}
		cout << ans << " ";
		//cerr << ans << endl;
		int sum = 0;
		int cnt = 0;
		if (ans == 0) {
			cout << m << endl;
			return ;
		}
		do{
			sum++;
			int maxa = 0, maxpos = 0;
			for (int i = 1; i <= m; i++) {
				if (h[i] == 1) continue;
				int res = 0;
				for (int j = 1; j <= n; j++)
					if (g[j] == 1 && f[j][i] == 1) res++;
				if (res > maxa) {
					maxa = res;
					maxpos = i;
				}
			}
			for (int j = 1; j <= n; j++)
				if (f[j][maxpos] == 1) g[j] = 2;
			h[maxpos] = 1;
			cnt = 0; 
			for (int i = 1; i <= n; i++)
				if (g[i] == 2) cnt++;
			//cerr<< cnt << endl;
		}
		while (cnt != ans);
		cout << m - sum << endl;
	}
}
namespace B{
	void solve() {
		int maxpos = 0;
		for (int i = 1; i <= m; i++)
			maxpos = max(maxpos, p[i]);
		int ans = 0;
		for (int i = 1; i <= n; i++)
			if (x[i].d <= maxpos && x[i].v > V) ans++;
		if (ans != 0) cout << ans << " " << m - 1 << endl;
		else cout << ans << " " << m << endl;
	}
}
int main(){
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	ios :: sync_with_stdio(false);
	int T;
	cin >> T;
	while (T--) {
		n = 0; m = 0; L = 0; V = 0;
		memset(f, 0, sizeof(f));
		memset(g, 0, sizeof(g));
		memset(h, 0, sizeof(h));
		cin >> n >> m >> L >> V;
		int flag = 0;
		for (int i = 1; i <= n; i++) {
			cin >> x[i].d >> x[i].v >> x[i].a;
			if (x[i].a != 0) flag = 1;
		}
		for (int i = 1; i <= m; i++)
			cin >> p[i];
		if (flag == 0) {
			B::solve();
		}
		else if (n <= 3000 && m <= 3000) {
			A::solve();
		}
		else cout << n  << " " << m - 1 << endl;
	}
	return 0;
}
